﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class HorizonDuctAndTerminalFilter : ISelectionFilter
	{
		public bool AllowElement(Element elem)
		{
			if (elem is Duct)
			{
				LocationCurve locationCurve = (elem as Duct).Location as LocationCurve;
				if (Math.Abs(locationCurve.Curve.GetEndPoint(0).Z - locationCurve.Curve.GetEndPoint(1).Z) < 0.0065616797900262466)
				{
					return true;
				}
			}
			else if (elem is FamilyInstance && elem.Category.Id.IntegerValue == -2008013)
			{
				return true;
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}
	}
}
